﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using ProBugTracker.Core;
using ProBugTracker.Domain;
using ProBugTracker.Core.Interface;
using ProBugTracker.Data.Interface;
using ProBugTracker.Data;

namespace ProBugTracker.Web
{
    [ServiceContract(Namespace = "")]
    [SilverlightFaultBehavior]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class UserHandlingService
    {
        private IUserManagerData _userManagerData;
        private IPermissionManagerData _permissionManagerData;
        private IRoleManagerData _roleManagerData;
        private IRoleManager _roleManager;

        public UserHandlingService()
        {
            this._userManagerData = new UserManagerData();
            this._permissionManagerData =new  PermissionManagerData();
            this._roleManagerData= new RoleManagerData();
            this._roleManager = new RoleManager(_roleManagerData, _permissionManagerData);
        }

        [OperationContract]
        public User LogInToSystem(string username,string password)
        {
            UserManager userManager = new UserManager(_userManagerData, _permissionManagerData, _roleManager);
            return userManager.ValidateLogInUser(username, password);
        }

        // Add more operations here and mark them with [OperationContract]
    }
}
